<template>
<view class="sq_page">
	<view class="top_div">
		<view class="back" :style="'top:'+navH+'px;'" @click="toBack"></view>
		<view class="input_view;" :style="'padding-top:'+navH+'px;'">
			<image style="height: 48px;" src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/dasdsadas.png" mode="heightFix"></image>
		</view>
		<view class="tt_mm">
			<image class="t_img" src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/34534534.png" mode="widthFix"></image>
			<view class="top_n">合伙人邀请函</view>
			<view class="top_x top_x1">我司诚挚向您发出邀请，成为合伙人</view>
			<view class="top_x top_x2">特发此函</view>
			<view class="top_x top_x3">福州易招商</view>
			<view class="top_x top_x4">{{year+'/'+month}}</view>
		</view>
	</view>
	<view class="heng"></view>
	<view class="sq_div">
		<view class="xm_div">
			<input type="text" v-model="form.nickname" placeholder="请输入姓名">
		</view>
		<button open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber" class="sq_btn">立即成为合伙人</button >
	</view>
</view>
</template>

<script>
	import { getWxappUserPhoneByCode,GetUseInfo,hhr } from '@/utils/api.js'
	export default {
		data() {
			return {
				navH:uni.getStorageSync('navH'),
				navH1:uni.getStorageSync('navH1'),
				navH2:uni.getStorageSync('navH2'),
				year:2022,
				month:1,
				form:{
					nickname:'',
					avatar:'',
					mobile:'',
				}
			}
		},
		onLoad() {
			let date = new Date()
			this.year =  date.getFullYear()
			this.month =  date.getMonth()+1
			GetUseInfo().then(res=>{
				this.form.nickname= res.data.nickname
				this.form.mobile= res.data.mobile
			})
		},
		onShareTimeline() {
			return {
				title: '申请加入合伙人 | 投资钟祥',
			}
		},
		onShareAppMessage() {
			return {
				title: '申请加入合伙人 | 投资钟祥',
			}
		},
		methods: {
			toBack(){
				uni.navigateBack()
			},
			onGetPhoneNumber(e){
				if(this.form.mobile){
					this.submit()
					return
				}
				getWxappUserPhoneByCode({code:e.detail.code}).then(res=>{
					if(res.data.phone_info.phoneNumber){
						this.form.mobile = res.data.phone_info.phoneNumber
						this.submit()
					}
				})
			},
			submit(){
				hhr.toAdd({...this.form,username:this.form.nickname}).then(res=>{
					if(res.status==1){
						uni.showToast({
							title:res.msg,
							icon:'success'
						})
						uni.navigateBack()
					}else{
						uni.showToast({
							title:res.msg,
							icon:'error'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
page{
	width: 100%;
	height: 100%;
}
.sq_page{
	background-color: #EAEBEF;
}
.back{
	position: fixed;
	left: 12px;
	width: 10px;
	height: 10px;
	margin-top: 14px;
	border-top: 2px solid #000;
	border-left: 2px solid #000;
	transform: rotate(-45deg);
}
.sq_div{
	width: calc(100% - 60px);
	padding: 15px 30px;
	background-color: #EAEBEF;
	box-shadow: 0 -2px 2px 0 rgba(0, 0, 0, 0.2);
	// min-height: 200px;
	.xm_div{
		border-radius: 4px;
		background-color: #fff;
		padding: 10px;
		width: calc(100% - 20px);
		margin-bottom: 16px;
		input{
			font-size: 16px;
		}
	}
	.sq_btn{
		border-radius: 4px;
		background:linear-gradient(45deg,#DF271F,#F17B6F);
		height: 42px;
		line-height: 42px;
		text-align: center;
		color: #fff;
		font-size: 16px;
	}
}
.input_view{
	text-align: center;
}
.heng{
	width: 100%;
	height: 20px;
	background-color: #F5F5F5;
}
.sq_page{
	min-height: 100%;
	.top_div{
		background: linear-gradient(45deg,#EBE9F6,#E4E7F5);
		.t_img{
			width: calc(100% - 20px);
			margin: 10px;
		}
	}
}
.tt_mm{
	position: relative;
	margin-top: 10px;
}
.top_n{
	position: absolute;
	top: 100px;
	font-size: 18px;
	font-weight: 800;
	color: #333;
	text-align: center;
	width: 100%;
}
.top_x{
	position: absolute;
}
.top_x1{
	top: 180px;
	font-size: 14px;
	color: #999;
	text-align: center;
	width: 100%;
}
.top_x2{
	top: 240px;
	font-size: 14px;
	color: #999;
	left: 80px;
}
.top_x2{
	top: 240px;
	font-size: 14px;
	color: #999;
	left: 80px;
}
.top_x3{
	bottom:110px;
	font-size: 14px;
	color: #999;
	right: 80px;
}
.top_x4{
	bottom: 88px;
	font-size: 14px;
	color: #999;
	right: 80px;
}
</style>